package com.wryyyyy.config;

import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import com.wryyyyy.utils.InfluxDBClientProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;

@Configuration
public class InfluxDBConfig {
    @Resource
    private InfluxDBClientProperties properties;

    public InfluxDBConfig(InfluxDBClientProperties properties) {
        this.properties = properties;
    }

    @Bean
    public InfluxDBClient influxDBClient() {
        return InfluxDBClientFactory.create(properties.getUrl(), properties.getToken().toCharArray(), properties.getOrg());
    }
}